package com.yf.biodemo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

/**
 * BIO 同步阻塞IO  客户端demo
 * @author yf
 */
public class BIOClient {
    public static void main(String[] args) throws IOException {
        int port=12000;
        Socket socket=new Socket("127.0.0.1",port);
        //输出流，给服务端发送消息
        PrintWriter out=new PrintWriter(socket.getOutputStream(),true);
        BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        out.println("server , hello");
        System.out.println("发送消息给服务器");
        //输入流，接收服务端响应消息
        String body=in.readLine();
        System.out.println("接收到服务器响应："+body);

        in.close();
        out.close();
        socket.close();
    }
}